//
//  PurchasePhoneTableViewHeaderView.m
//  GLGW_Shoping
//
//  Created by yang on 2018/12/3.
//  Copyright © 2018年 yang. All rights reserved.
//

#import "PurchasePhoneTableViewHeaderView.h"

static BOOL butSelect = NO;

@implementation PurchasePhoneTableViewHeaderView

-(instancetype)initWithReuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithReuseIdentifier:reuseIdentifier]) {
        GLGWView * bankgroundView = [[GLGWView alloc] initWithInSuperView:self.contentView];
        bankgroundView.backgroundColor = [UIColor whiteColor];
        [bankgroundView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.edges.equalTo(self.contentView);
        }];
        //
        GLGWButton * but = [[GLGWButton alloc] initWithTitle:@"隐藏详情" titleLableFont:SYSTEMFONT(14) titleLableColor:[UIColor colorWithHexString:@"#999999"] inSuperView:bankgroundView];
        but.selected = butSelect;
        [but mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(bankgroundView.mas_right).offset(-kWidthProportion_In_iPhoneTriploid(15));
            make.top.equalTo(bankgroundView.mas_top).offset(0);
            make.width.equalTo(@(kWidthProportion_In_iPhoneTriploid(100)));
            make.height.equalTo(@(kHeightProportion_In_iPhoneTriploid(30)));
        }];
        but.contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight;
        [but setImage:[UIImage imageNamed:@"icon_xiala"] forState:UIControlStateNormal];
        [but setImagePositionWithType:SSImagePositionTypeRight spacing:5];
        [but addTarget:self action:@selector(openAndCloseAction:) forControlEvents:UIControlEventTouchUpInside];
    }
    return self;
}

-(void)openAndCloseAction:(GLGWButton *)sender{
    sender.selected = !sender.selected;
    butSelect = sender.selected;
    if (self.Block_OpenAndCloseAction) {
        self.Block_OpenAndCloseAction(sender.selected);
    }
}

@end
